﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using WPFExcelReport.Helpers;
using System.Collections;
using System.Collections.Generic;
namespace WPFExcelReport
{
    public partial class TSEK02
    {

        ITXEXRPT ITXEXRPT;
        public TSEK02()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VEKPOS();
            this.DataContext = MV;
            InitializeComponent();
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            dwEKP = dwMaster;
            if (dwMaster == null)
            {
                EXAUF = "";
            }
            else
            {
                EXAUF = "B" + TMV.EKPAUFKRS + TMV.EKPAUFLFD + TMV.EKPAUFPOS;

            }
        }
        public override void Query_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key != System.Windows.Input.Key.Return || e.Key != System.Windows.Input.Key.Enter)
                return;
            QueryCommand(null, null);
        }
        public override void QueryCommand(object sender, RoutedEventArgs e)
        {
            
            TBMain.Clear();
            dwData = TBMain.NewRow(); 
            dwData["EKPMANDANT"] = app.Mandant;
            dwData["EKPAUFKRS"] =  " AND EKPAUFKRS LIKE '%" + KRS.Trim() + "%'"
                  + " AND EKPAUFLFD LIKE '%" + LFD.Trim() + "%'"
                  + " AND EKPLIEFNR LIKE '" + DES.Trim() + "%'"
                  + " AND utl_raw.cast_to_varchar2(EKPART) LIKE '%"+ART.Trim()+"%'";
            SResult = TMV.QEK14(dwData);
            MergeData(SResult, false);
            base.QueryCommand(sender, e);
            IsQuery = false;
        }
        private void CloseEKPCommand(object sender, RoutedEventArgs e)
        {
            if (dwMaster == null)
                return;
            
            dwMaster["EKPGESSTA"] = "KO";
            TMV.UEKP13(dwMaster);
        }



    }
}
